import { WhiteListManager } from "GameLoop/WorldState/EngineConfig/WhiteListManager";

 

 
/**
 * 房间的基础功能.
 * 1.维持能量的正常运转
 * 2.维持房间爬的正常数量
 */
export default class FunctionalExtension extends Room 
{
    public activeSafeMode()
    {
        const spawnentity = this.getEntity("SpawnEntity");
        if(this.controller?.safeMode)
        {
            return OK;
        }
        if(spawnentity.spawnStructures().length)
        {
            if(this.controller?.safeModeCooldown === 0)
            {
                this.controller?.activateSafeMode();
                return OK;
            }
            return -1;
        }
        return -2;
    }

    public findHostileCreeps()
    {
        return  this.find(FIND_HOSTILE_CREEPS,{filter:creep=>!WhiteListManager.IsFriendCreep(creep)})
    }
}
